package joodle.tools;

import java.awt.Graphics;

import joodle.domain.Point;

/**
 * Tool interface is the root interface of all the tools available in joodle. Its methods include 
 * handlePress for handling mouse clicks, handleMove for handling mouse movements and handleRelease 
 * for handling mouse release events. Each of these methods also accepts two Boolean parameters as 
 * indicators of the state of the left mouse button and the ctrl key at the time of the mouse event. 
 * UI classes will use this interface as a mediator between the User and the Domain objects. The 
 * drawInterim method is responsible for drawing intermediate figures as indicators of the current 
 * state of the Tool (the angle of rotation in RotationTool, etc). joodle provides four kinds of tools 
 * out of box: Creation tool for creating new shapes on the Canvas, Selection tool for selecting one 
 * or more shapes from the Canvas and Transformation tools for transforming a shape on Canvas.
 * <p><center>
 * <img src="http://ug.bcc.bilkent.edu.tr/~m_ozdal/Site/Reports_files/design_files/image005.jpg" />
 * </center></p>
 */
public interface Tool {
	/**
	 * Invoked when the mouse button has been clicked (pressed and released) on a component.
	 * @param p point that mouse is clicked on
	 * @param ctrl boolean value that indicates whether the mouse is clicked by holding ctrl key or not
	 */
	void handlePress(Point p, boolean ctrl);
	
	/**
	 * Invoked when the mouse cursor has been moved onto a component.
	 * @param p point that mouse is moved on
	 * @param ctrl boolean value that indicates whether the mouse is moved by holding ctrl key or not
	 * @param lb boolean value that indicates whether the mouse is moved by holding left mouse button 
	 * or not
	 */
	void handleMove(Point p, boolean ctrl, boolean lb);
	
	/**
	 * Invoked when a mouse button has been released on a component.
	 * @param p point that mouse is released on
	 * @param ctrl boolean value that indicates whether the mouse is released by holding ctrl key or 
	 * not
	 */
	void handleRelease(Point p, boolean ctrl);
	
	/**
	 * Invoked when a key has been pressed.
	 * @param c integer value that indicates the pressed key. For example, if the escape key is pressed,
	 * then c has a value 27 or if the backspace key is pressed, then c has a value 8.
	 */
	void handleKeyPress(int c);
	
	/**
	 * Invoked when a key has been typed.
	 * @param c character that indicates the key associated with the specific attribute
	 */
	void handleKeyType(char c);
	
	/**
	 * Responsible for drawing intermediate figures as indicators of the current 
	 * state of the Tool (the angle of rotation in RotationTool, etc).
	 * @param g the graphics context to use for drawing
	 */
	void drawInterim(Graphics g);
}
